<html>
<head>
	<title>T2.11</title>
	<script type="text/javascript">
		var request = new XMLHttpRequest();
		function pedir() {
			peticion_str = '/~inaki/cgi-bin/11-servidor.py?mode=get';
			request.open('GET', peticion_str, true);
			request.onreadystatechange = escribe;
			request.send(null);
		}
		function cambiar() {
			var id = document.getElementById('id').value;
			var content = document.getElementById('content').value;
			var peticion_str = '/~inaki/cgi-bin/11-servidor.py?mode=modify&id='+id+'&content='+content;
			request.open('GET', peticion_str , false);
			request.send(null);
			pedir();
		}
		function escribe() {
			if ( request.readyState == 4 ) {
				if ( request.status == 200 ) {
					var doc = request.responseXML;
					var xmlString = (new XMLSerializer()).serializeToString(doc);
					xmlString = xmlString.replace(/quiniela/g, 'ol')
								.replace(/partido/g, 'li')
								.replace(/<visitante>/g, '- <visitante>')
								.replace(/<resultado>/g, '= <resultado>');
					document.getElementById('fichero').innerHTML = xmlString;
				}
			}
		}
	</script>
</head>
<body onload="pedir();">
	Partido:
	<select id="id">
		<option>1</option>
		<option>2</option>
		<option>3</option>
		<option>4</option>
		<option>5</option>
		<option>6</option>
		<option>7</option>
		<option>8</option>
		<option>9</option>
		<option>10</option>
		<option>11</option>
		<option>12</option>
		<option>13</option>
		<option>14</option>
		<option>15</option>
	</select>
	Resultado:
	<select id="content">
		<option>1</option>
		<option>x</option>
		<option>2</option>
	</select>
	<input type="button" id="button" value="Cambiar" onclick="cambiar();" />
	<div id="fichero"></div>
</body>
</html>